<?php

class PublicController extends FrontBaseC{

	public function actionTaoData(){
        $url = Yii::app()->request->getParam('url');
        if (empty($url)) {
            $this->ajaxReturn(array('status' => 0));
        }

        $data = TaobaoApi::getDataUrl($url);
        
        if (empty($data)) {
            $data = array('status' => 0);
        } else {
            $data['status'] = 1;
        }
        $this->ajaxReturn($data);		
	}

    /**
     * 上传图片
     * @return [type] [description]
     */
    public function actionUpload(){
        //上传后返回其路径。
        UploadFile::getInstance()->upload($_POST['path'], $_POST['name']);
        $arrFile = UploadFile::getInstance()->getArrSuccess();
        if(!empty($arrFile)){
            echo $arrFile['file']['filename'];  
        }   
    }
    /**
     * 删除图片
     * @return [type] [description]
     */
    public function actionDeleteImg(){
        if(empty($_POST['filename'])){
            $this->error('参数有误');
        }
        UploadFile::deleteImg($_POST['filename']);      
    }
    /**
     * 错误页面
     * @return [type] [description]
     */
    public function actionError(){
        $redis = RedisCluster::getInstance()->getRedis();
        $arr = array(
            'Get' => json_encode($_GET),
            'Post' => json_encode($Post),
            'Url' => Yii::app()->request->hostInfo . Yii::app()->request->getUrl(),
            'UserID' => yii::app()->user->id,
        );
        RedisCluster::getInstance()->push('public_error', $arr);
        $this->render();
    }
} 